﻿using Generic.App.Application.Contracts.Service;
using Generic.Domain.Shared.Result;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Converters;
using System.Text.Json.Serialization;

namespace Generic.App.HttpApi.Controllers
{
    public class AppTokenGreyController : BaseApiController
    {
        private readonly IAppTokenGreyService _appTokenGreyService;
        public AppTokenGreyController(IAppTokenGreyService appTokenGreyService)
        {
            _appTokenGreyService = appTokenGreyService;
        }

        [HttpPost]
        public async Task<CustomResult> InsertAsync(string token)
        {
            string operateUser = GetOperateId();
            return new CustomResult(await _appTokenGreyService.InsertAsync(token, operateUser));
        }

        [HttpPost]
        public async Task<CustomResult> TestDateAsync(DateTime time)
        {
            return new CustomResult(await Task.FromResult(time));
        }

        [HttpPost]
        public async Task<CustomResult> TestDateJsonAsync(TimeClass time)
        {
            return new CustomResult(await Task.FromResult(time.GetDate));
        }

        public class TimeClass
        {
            public DateTime GetDate { get; set; }
        }
    }
}
